package com.gxuwz.bignews.controller;

import android.content.Context;
import android.content.SharedPreferences;

import com.gxuwz.bignews.model.db.UserDao;
import com.gxuwz.bignews.model.entity.User;

public class ResetPasswordController {
    private UserDao userDao;
    private Context context;

    public ResetPasswordController(Context context) {
        this.context = context;
        userDao = new UserDao(context);
    }

    public boolean isPhoneRegistered(String phone) {
        return userDao.isPhoneRegistered(phone);
    }

    public boolean resetPassword(String phone, String newPassword) {
        return userDao.updatePassword(phone, newPassword);
    }
    
    public boolean verifyOldPassword(String phone, String oldPassword) {
        User user = userDao.getUserByPhoneAndPassword(phone, oldPassword);
        return user != null;
    }
    
    public String getCurrentUserPhone() {
        SharedPreferences sp = context.getSharedPreferences("user_info", Context.MODE_PRIVATE);
        return sp.getString("phone", "");
    }
} 